<template>
	<view class="page">
		<view class="feedback-title"><text>对本次维修的满意度</text></view>
		<view style="background: white;padding:20upx 10upx;">
			<radio-group @change="radioChange">
				<label class="radio">
					<radio value="非常满意" checked="true" />
					非常满意
				</label>
				<label class="radio">
					<radio value="满意" />
					满意
				</label>
				<label class="radio">
					<radio value="一般" />
					一般
				</label>
				<label class="radio">
					<radio value="不满意" />
					不满意
				</label>
			</radio-group>
		</view>

		<view class="feedback-title"><text>评价内容</text></view>
		<view class="feedback-body"><textarea placeholder="请输入您的意见或建议..." v-model="content" class="feedback-textare" /></view>
		<button type="primary" class="feedback-submit" @tap="send">提交</button>
	</view>
</template>
<script>
import { mapState, mapMutations } from 'vuex';
import uniRate from '@/components/uni-rate/uni-rate.vue';
export default {
	data() {
		return {
			content: '',
			id: '',
			satisFaction:'非常满意',
		};
	},
	methods: {
		...mapMutations(['TO_UPDATE']),
		radioChange: function(e) {
           console.log(e.detail.value);
		   this.satisFaction = e.detail.value;
        },
		onChange(e) {
			console.log('rate发生改变:' + JSON.stringify(e));
		},
		send() {
			//发送反馈
			uni.request({
				url: this.URL + 'bxTEstimate/comment',
				data: {
					mainId: this.id,
					esContent: this.content,
					esPingfen:this.satisFaction,
				},
				header: {
					token: this.TOKEN
				},
				success: res => {
					this.TO_UPDATE(true);
					uni.showToast({
						title: res.data.message,
						icon: 'none'
					});
					if (res.data.success) {
						setTimeout(() => {
							uni.navigateBack();
						}, 2000);
					}
					console.log(JSON.stringify(res.data));
				}
			});
		}
	},
	onLoad(e) {
		this.id = e.id;
	},
	components: {
		uniRate
	},
	computed: {
		...mapState(['TOKEN', 'UPDATE', 'URL'])
	}
};
</script>

<style>
.page {
	background-color: #efeff4;
	width: 750upx;
}

.input-view {
	font-size: 28upx;
}
</style>
